<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="css/base/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/base/Buttons.css" />
		<link rel="stylesheet" type="text/css" href="css/base/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/base/jqueryweui.css" />
		<style type="text/css">
			* {
				margin: 0px;
				padding: 0px;
				border: 0px;
			}
			
			body {
				background: #F7FAFC;
			}
			
			.logo {
				display: block;
				width: 100px;
				height: 100px;
				margin: auto;
				margin-top: 20px;
				margin-bottom: 10px;
				font-size: 100px;
				font-weight: bolder;
				color: #0F88EB;
			}
			
			.txt {
				display: block;
				text-align: center;
				height: 50px;
				line-height: 50px;
				font-size: 18px;
				color: #666666;
			}
			
			.username {
				display: block;
				border: 1px solid #D5D5D5;
				outline: none;
				text-align: center;
				line-height: 50px;
				width: 90%;
				height: 50px;
				font-size: 16px;
				margin: 20px auto;
				background: rgba(255, 255, 255, 1);
			}
			
			.mail {
				width: 90%;
				height: 40px;
				border: 1px solid #D5D5D5;
				margin: auto;
				line-height: 40px;
				text-align: center;
				outline: none;
				font-size: 16px;
				background: rgba(255, 255, 255, 1);
			}
			
			.mail:empty:before,
			.username:empty:before {
				content: attr(placeholder);
				font-size: 18px;
				color: #d5d5d5;
			}
			
			.mail:focus:before,
			.username:focus:before {
				content: none;
			}
			
			.password,
			#phone,
			#idCard {
				display: block;
				width: 90%;
				height: 40px;
				border: 1px solid #D5D5D5;
				margin: 20px auto;
				line-height: 40px;
				text-align: center;
				outline: none;
				font-size: 16px;
				background: rgba(255, 255, 255, 1);
			}
			
			.button {
				display: block;
				width: 90%;
				margin: auto;
			}
			
			.reg-login {
				height: 50px;
				line-height: 70px;
				display: block;
				font-size: 14px;
				width: 90%;
				text-align: right;
			}
			
			a {
				text-decoration: none;
				color: #666666;
			}
		</style>
	</head>

	<body>
		<span class="logo Hui-iconfont Hui-iconfont-home"></span>
		<span class="txt">天津智能公共自行车</span>

		<div class="mail" id="userName" placeholder='姓名' contenteditable="true"></div>
		<input class="phone" type="number" id="idCard" placeholder='身份证号' />
		<input class="phone" type="number" id="phone" placeholder='手机号' />
		<div class="mail" id="register_email" placeholder='注册邮箱' contenteditable="true"></div>
		<input class="password" type="password" id="register_pwd" placeholder='密码' />
		<input class="password" type="password" id="register_rpwd" placeholder='请重新输入密码' />
		<a href="javascript:;" class="button button-3d button-primary button-rounded register_click">注册</a>
		<span class="reg-login"><a href="login.html">返回登录</a></span>
	</body>
	<script src="js/base/av-min-2.1.2.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/base/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>

	<script type="text/javascript">
		//接入leanCloud注册邮箱
		var APP_ID = 'hN1kSQf2DQ9awcJmwEmIIdVo-gzGzoHsz';
		var APP_KEY = 'aHCVjhhcyeerTEsKObkGSyd6';

		AV.init({
			appId: APP_ID,
			appKey: APP_KEY
		});

		$(".register_click").click(function() {
			var register_userName = $("#userName").html();
			var register_idCard = $("#idCard").val();
			var register_phone = $("#phone").val();
			var register_email = $("#register_email").html();
			var register_pwd = $("#register_pwd").val();
			var register_rpwd = $("#register_rpwd").val();
			console.log(register_userName)
			console.log(register_idCard)
			console.log(register_phone + "---" + register_email + "--" + register_pwd + "--" + register_rpwd)
			if(register_pwd != register_rpwd) {
				alert("两次输入密码不同，请重新输入")
			} else {
				// 声明类型
				var User_info = AV.Object.extend('user_info');
				// 新建对象
				var User_info = new User_info();
				// 设置邮箱
				User_info.set('email', register_email);
				// 设置密码
				User_info.set('Password', register_pwd);
				// 设置身份证号
				User_info.set('idCard', register_idCard);
				// 设置手机号
				User_info.set('phoneNumber', register_phone);
				// 设置姓名
				User_info.set('userName', register_userName);
				User_info.save().then(function(todo) {
					alert('注册成功');
					location.href = 'login.html'
				}, function(error) {
					alert('注册失败');
				});
			}
		})
	</script>

</html>